A cold start occurs when AWS Lambda initializes a new execution environment in response to an invocation, which adds latency before the function begins execution. This typically happens when a function is invoked after a period of inactivity or when scaling to handle concurrent requests. Cold starts are more noticeable in VPC-connected functions and interpreted languages like Python and Node.js.
First-time invocation after deployment or inactivity
Scaling to new concurrent executions beyond warm environments
Using VPCs without properly configured networking
Large dependencies that slow down initialization
Use provisioned concurrency to keep instances warm
Minimize the size of your deployment package
Avoid unnecessary VPC usage or use efficient VPC configurations
Use lighter runtimes like Go or Node.js for faster start-up
Keep initialization code outside the handler function